package com.xja.shoppingmall.service;

import brave.Tracer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author CHENCHEN
 * @title   使用代码 查看 Sleuth生成的相关跟踪信息
 * @createTime 2021-12-1222:31
 */
@Slf4j
@Service
public class SleuthTraceInfoService {

    @Autowired
    private Tracer tracer;

    public void logCurrentTraceInfo(){
        log.info("Sleuth trace id : [{}]",tracer.currentSpan().context().traceId());
        log.info("Sleuth span id : [{}]",tracer.currentSpan().context().spanId());
    }
}
